package mytest.jedis.advanced;

import redis.clients.jedis.JedisPubSub;

public class MyListener extends JedisPubSub {
	public void onMessage(String channel, String message) {
		System.out.println("onMessage方法，channel：" + channel + " ： " + message);
	}
	
	/**
	 * param1:channel表示订阅的值(jedis.subscribe输入的值)
	 * param2:subscribedChannels表示服务器端返回的订阅渠道在哈希表总的顺序值
	 * 
	 * 这种模式属于频道模式，每订阅一个输出一个结果
	 */
	public void onSubscribe(String channel, int subscribedChannels) {
		System.out.println("onSub方法，channel：" + channel + " ; subscribedChannels：" + subscribedChannels);
	}

	public void onUnsubscribe(String channel, int subscribedChannels) {
	}

	/**
	 * 表达式渠道，模糊匹配
	 */
	public void onPSubscribe(String pattern, int subscribedChannels) {
		System.out.println("onPSubscribe方法，pattern：" + pattern + "；subscribedChannels：" + subscribedChannels);
	}

	public void onPUnsubscribe(String pattern, int subscribedChannels) {
	}

	public void onPMessage(String pattern, String channel, String message) {
		System.out.println("onPMessage方法，channel：" + channel + " ： " + message);
	}
}
